package com.mall.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import redis.clients.jedis.Jedis;

@Configuration  // 配置类    与@Bean一起使用
@PropertySource("classpath:/redis.properties")
public class RedisConfig {

    // 用redis来做缓存

    @Value("${redis.port}")
    private String port;
    @Value("${redis.host}")
    private String host;

    @Bean
    public Jedis jedis(){
        return new Jedis(host, Integer.parseInt(port));
    }

}
